package cn.wokoba.service.activity.service.trial.thread;

import cn.wokoba.service.activity.adapter.repository.IActivityRepository;
import cn.wokoba.service.activity.model.valobj.GroupBuyActivityDiscountVO;

import java.util.concurrent.Callable;

public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {
    /**
     * 来源
     */
    private final String source;

    /**
     * 渠道
     */
    private final String channel;

    /**
     * 商品ID
     */
    private final String goodsId;
    /**
     * 活动仓储
     */
    private final IActivityRepository activityRepository;

    public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, String goodsId, IActivityRepository activityRepository) {
        this.source = source;
        this.channel = channel;
        this.goodsId = goodsId;
        this.activityRepository = activityRepository;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        Long activityId = activityRepository.queryScSkuActivityBySCGoodsId(source,channel,goodsId);
        return activityId == null ? null : activityRepository.queryGroupBuyActivityDiscountVO(activityId);
    }
}
